package trytry;

public class Car {
    private int speed;
    private String carname;
    private String engine;
    public Car(int speed,String carname,String enging){
        this.carname = carname;
        this.speed = speed;
        this.engine =enging;

    }

    public Car() {

    }

    public void print_speed()throws MyException{
            System.out.println("您的车速是："+speed);
            if (speed>=100){
                throw new MyException(speed);
            }
    }

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed)throws MyException {
        if (speed>100){
            throw new MyException(speed);
        }
        System.out.println("设置车速为："+speed);
        this.speed = speed;
    }
}
